package dp

// https://leetcode-cn.com/problems/fibonacci-number/
// 斐波那契数
// 算法：动态规划
// f[n] = f[n-1] + f[n-2]
func Fib(n int) int {
	if 0 == n {
		return 0
	}
	arr := make([]int, 30)
	arr[0], arr[1] = 1, 1
	for i := 2; i <= n-1; i++ {
		arr[i] = arr[i-1] + arr[i-2]
	}
	return arr[n-1]
}
